package com.smart.core.starter.base;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.core.starter.model.PageParam;
import lombok.extern.slf4j.Slf4j;


/**
 * BaseController
 * @author guxiaobai
 * @date 2018/11/28 20:54
 */
@Slf4j
public class BaseController {



	protected <T> Page<T> getPage(PageParam pageParam) {
		Page<T> page = new Page<T>(pageParam.getPageNo(), pageParam.getPageSize());
		if (page.getSize() > PageParam.MAX_PAGE_SIZE){
			page.setSize(PageParam.MAX_PAGE_SIZE);
		}
		page.setAsc(pageParam.getAscFields());
		page.setDesc(pageParam.getDescFields());
		return page;
	}


}
